from django.db import models

class Cliente(models.Model):
	nome = models.CharField(max_length=64)
	telefone = models.CharField(max_length=16, blank=True, null=True)
	
	def __unicode__(self):
		return u"%s:%s" % (self.id, self.nome)
	
PIZZAS = (
	(1, "Muzzarela"),
	(2, "Calabreza"),
	(3, "Margerita"),
	)
	
class Pedido(models.Model):
	cliente = models.ForeignKey("Cliente")
	pizza = models.IntegerField(choices=PIZZAS)
	data_pedido = models.DateTimeField(auto_now_add=True)
	data_entrega = models.DateTimeField(blank=True, null=True)
	entregador = models.ForeignKey("Entregador", blank=True, null=True)
	
	@models.permalink
	def get_absolute_url(self):
		return "pedido_detail", "", {"object_id": self.id}
	
	def entregue(self):
		return bool(self.data_entrega)
	entregue.boolean = True
		

class Entregador(models.Model):
	nome = models.CharField(max_length=64)
	
	def __unicode__(self):
		return u"%s" % (self.nome)
	
	class Meta:
		verbose_name_plural = "Entregadores"
		
	
